/**
 *	TrueMusic - simple java mp3 player
 *
 *	TrueMusic is free software; you can redistribute it
 *	and/or modify it under the terms of the GNU General
 *	Public License as published by the Free Software
 *	Foundation; either version 2 of the License or (at
 *	your option) any later version.
 *	
 *	This program is distributed in the hope that it will be
 *	useful but WITHOUT ANY WARRANTY; without even the 
 *	implied warranty of the MERCHANTABILITY or FITNESS FOR
 *	A PARTICULAR PURPOSE. See the GNU General Public
 *	License for more details.
 *	
 *	Copyright (c)2005-2006 Ryan Macnak <ambiguousprep@gmail.com>
 */

package com.servequake.truemusic;

import java.io.*;
import java.applet.*;

// basic audio formats supported by java.applet.AudioClip
public class AppletClipAudioFile extends AudioFile
{
	public void dispose()
	{
		a.stop();
		a=null;
	}

	AudioClip a;

	File f;

	AppletClipAudioFile(File f) throws Exception
	{
		this.f = f;

		a = Applet.newAudioClip(f.toURL());
	}

	public String filename()
	{
		return f.toString();
	}


	public void play()
	{
		new Thread()
		{
			public void run()
			{
				a.play();
			}
		}.start();
	}	

	public void pause(){}

	public void stop2()
	{
		a.stop();
	}

	public void setPos(int n){}

////////////////////

	public String getTitle()
	{
		return f.toString();
	}

	public String getArtist()
	{
		return "(this audio format does not";
	}
	public String getAlbum()
	{
		return "support seek or autonext functions)";
	}
	public int getFrames()
	{
		return 1;
	}
	public String toString()
	{
		return f.toString();
	}
}